﻿
<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>权限角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script> 
    @* <script src="~/js/layui/layui.js"></script> *@
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
</head>
<body>
    <ul lay-bar="disabled" class="mWebBanner">
        <li class="layui-nav-item" style="float:left;">
            <button id="btn-update" type="button" name="btn_update" onclick="SaveData()" class="buttonCss">
                确认保存
            </button>
        </li>
        <li class="layui-nav-item" style="float:left;margin-left:3%">
            <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                关闭页面
            </button>
        </li>
    </ul>
    <div class="layui-card" style="margin-top:10px">
        <div class="layui-card-body" style="padding-top:4%">
            <form class="layui-form" id="AddForm">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>角色名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="groupName" name="groupName" required="" autocomplete="off" class="layui-input">
                        <input id="id" name="id" type="hidden"/>
                    </div>
                   
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>角色说明
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="memo" name="memo" required="" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>权限角色备注说明
                    </div>
                </div>
            </form>
        </div>
            
     </div>

   
</body>
</html>
<script type="text/javascript">
    var dataId = "";
    $(function () {
        dataId = getUrlVariable("dataId");
        if (dataId != "0") {
            $("input[ name='id']").val(dataId);
            loadData(dataId);
        }

    });

    /**
    保存数据
    **/
    function SaveData() {
        $.ajax({
            url: "../System/UpdatePowerRole",
            data: { datas: JSON.stringify(FormToJson("AddForm")) },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    //layer.msg("数据保存成功");
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

    /**
    加载数据信息
    **/
    function loadData(dataId) {
        $.ajax({
            url: "../System/getRoleById",
            type: "post",
            data: { dataKey: dataId },
            success: function (data) {
                if (data.result) {
                    $.each(data.data[0], function (name, value) {
                        $("input[ name='" + name + "']").val(value);
                    });
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            }
        });
    }


</script>